package com.rslai.base.tool.servertest.dsl;

import com.rslai.base.tool.servertest.annotation.ChildrenConfig;
import com.rslai.base.tool.servertest.annotation.Property;
import com.rslai.base.tool.servertest.command.CommandFactory;
import com.rslai.base.tool.servertest.config.StepConfig;
import com.rslai.base.tool.servertest.reporter.Reporter;

import java.util.List;
import java.util.Map;

public class DefineDSLCommand {

    @Property(required = true)
    private String id;

    @Property(required = true)
    private String desc;

    @Property(defaultValue = "false")
    private String runOnce;

    @ChildrenConfig
    private List<StepConfig> children;
    private Map<String, Map<String, Object>> data;

    public void define(Reporter reporter) {
        DSLCommandDesc dslCommandDesc = new DSLCommandDesc(this.id, this.desc, Boolean.valueOf(this.runOnce), this.children, this.data);
        reporter.addDSLCommand(dslCommandDesc);

        DSLCommandConfig.map(this.id, dslCommandDesc);
        CommandFactory.getInstance().addConfig(this.id, DSLCommandConfig.class);
    }

    public String getId() {
        return this.id;
    }

    public Map<String, Map<String, Object>> getData() {
        return this.data;
    }

    public void setData(Map<String, Map<String, Object>> data) {
        this.data = data;
    }

    public void setId(String id) {
        this.id = id;
    }
}
